package com.wang.interview.tests.threadtest;

import java.util.concurrent.TimeUnit;

/**
 * @author: wang
 * @date: 2021/8/5 20:48
 * @description:
 */
public class T1 {
    public static void main(String[] args) throws InterruptedException {
        Thread a = new Thread(() -> {
            System.out.println(" A ");
            try {
                TimeUnit.SECONDS.sleep(60);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "A");
        a.start();
        System.out.println(a.isInterrupted());
        TimeUnit.SECONDS.sleep(5);
        a.interrupt();
        System.out.println(a.isInterrupted());



    }
}
// 可以同时启动多个main线程
class A{
    static int num = 1;
    public static void main(String[] args) throws InterruptedException {
        TimeUnit.SECONDS.sleep(100);
        System.out.println(num++);
    }
}
class B{
    public static void main(String[] args) throws InterruptedException {
        TimeUnit.SECONDS.sleep(100);
        System.out.println(A.num);
    }
}

// 继承的线程可以多次start
class C extends Thread{
    public static void main(String[] args) {
        Thread a = new Thread();
        a.start();
        a.start();
    }

    @Override
    public void run() {
        super.run();
    }
}
